﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09_C_中深拷贝和浅拷贝的理解
{
    internal class Teacher
    {
        public int TeacherID { get; set; }

        public string TeacherName { get; set; }

        public Student StudentModel { get; set; }

        public Teacher Clone()
        {
            // 使用 MemberwiseClone() 创建浅拷贝 //引用类型复制的引用
            return (Teacher)this.MemberwiseClone();
        }

        public Teacher DeepClone()//手动深度拷贝
        {
            Teacher tempTeacher = (Teacher)this.MemberwiseClone();
            tempTeacher.StudentModel = new Student();
            return tempTeacher;
        }
    }
}
